# Contributor: Ed Robinson <ed@reevoo.com>
# Maintainer: Ed Robinson <ed@reevoo.com>
pkgname=fontforge
pkgver=20220308
pkgrel=1
pkgdesc="free (libre) font editor for Windows, Mac OS X and GNU+Linux"
url="https://fontforge.org/"
arch="all !s390x"
license="GPL-3.0-or-later"
makedepends="
	cmake
	giflib-dev
	gtk+3.0-dev
	libspiro-dev
	libxml2-dev
	pango-dev
	potrace
	python3-dev
	readline-dev
	samurai
	tiff-dev
	woff2-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	py3-$pkgname:_py3
	"
source="https://github.com/fontforge/fontforge/releases/download/$pkgver/fontforge-$pkgver.tar.xz
	fix-select.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DENABLE_GUI=ON \
		-DENABLE_X11=OFF \
		-DENABLE_PYTHON_SCRIPTING=ON \
		-DENABLE_PYTHON_EXTENSION=ON \
		-DENABLE_LIBSPIRO=ON \
		-DENABLE_LIBGIF=ON \
		-DENABLE_LIBJPEG=ON \
		-DENABLE_LIBPNG=ON \
		-DENABLE_LIBREADLINE=ON \
		-DENABLE_LIBTIFF=ON \
		-DENABLE_WOFF2=ON \
		-DENABLE_DOCS=OFF \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

_py3() {
	pkgdesc="python3 bindings for $pkgname"

	amove usr/lib/python3.*
	amove usr/share/fontforge/python
}

sha512sums="
9975cffec8aa47bcb8c22405bea544cd263dc939b253e8fba2fbaa3b90a60e05b98eaf58365db8ae854d1fff8e641866a7e2e027003ae03a77104d6650dafb6c  fontforge-20220308.tar.xz
8cb3fb00fa537eab2d4b194916343a0e2aab85c2415a1944c0d0e648d62a7748d5d4465fb99cb92385b749e73abfcaa429f4c9d2bb4c2edea8febeb227add93a  fix-select.patch
"
